<template>
  <el-button @click="changeLanguage">语言切换 --- {{ userTodo.locale }}</el-button>
  <div>{{ $t("login.languageToggle") }}</div>
</template>

<script setup>
import { useI18n } from 'vue-i18n';
import useTodosStore from "./store/todos.js";

const { locale: i18nLocale } = useI18n();
const userTodo = useTodosStore();

const changeLanguage = () => {
  const newLocale = userTodo.locale === "zh-cn" ? "en" : "zh-cn";
  userTodo.changeLocale(newLocale);
  i18nLocale.value = newLocale; // 更新i18n的语言设置
}
</script>

<style scoped>
</style>
